<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='plugins/layui/css/layui.css') }}">
    <style>
        form{
            width: 500px;
        }
        .layui-form-item {
            margin-top: 20px;

        }
    </style>
</head>
<body>
<form class="layui-form" >

    <div class="layui-form-item" >
        <input id="id" type="hidden" name="id" value="{{ user.id }}">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input id="username" type="email" name="username" value="{{ user.username }}" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input id="password" type="password" name="password" value="{{ user.password }}" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <input type="hidden" id="sex" value="{{ user.sex }}">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-block">
            <input lay-filter="sex-filter" type="radio" name="sex" value="0" title="男" {% if user.sex == 0 %}checked{% endif %}>
            <input lay-filter="sex-filter" type="radio" name="sex" value="1" title="女" {% if user.sex == 1 %}checked{% endif %}>
            <input lay-filter="sex-filter" type="radio" name="sex" value="2" title="保密" {% if user.sex == 2 %}checked{% endif %}>
        </div>
    </div>
</form>
<script src="/static/plugins/layui/layui.js"></script>
<script src="/static/js/jquery.min.js"></script>
<script>

    layui.use(function(){
        var form = layui.form;
        var $ = layui.$;
        form.on('radio(sex-filter)', function(data){
            $('#sex').val(data.elem.value)
        });


    })
</script>
</body>
</html>